﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_BaseExpressInc.cs
文件名称：BaseExpressInc.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-01-10
作　　者：
内容摘要：表[Base_Express_Inc]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：BaseExpressInc
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class BaseExpressInc : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is BaseExpressInc)
				{
					if (obj == this)
						return true;
					BaseExpressInc castObj = (BaseExpressInc)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_CompanyName.Equals(castObj.CompanyName))
						return false;
						
					if (!this.m_QueryUrl.Equals(castObj.QueryUrl))
						return false;
						
					if (!this.m_Desc.Equals(castObj.Desc))
						return false;
						
					if (!this.m_CreateDate.Equals(castObj.CreateDate))
						return false;
						
					if (!this.m_CreateBy.Equals(castObj.CreateBy))
						return false;
						
					if (!this.m_LastUpdateDate.Equals(castObj.LastUpdateDate))
						return false;
						
					if (!this.m_LastUpdateBy.Equals(castObj.LastUpdateBy))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CompanyName != null)
					{
						hash = hash ^ m_CompanyName.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_QueryUrl != null)
					{
						hash = hash ^ m_QueryUrl.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Desc != null)
					{
						hash = hash ^ m_Desc.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateDate != null)
					{
						hash = hash ^ m_CreateDate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateBy != null)
					{
						hash = hash ^ m_CreateBy.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LastUpdateDate != null)
					{
						hash = hash ^ m_LastUpdateDate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LastUpdateBy != null)
					{
						hash = hash ^ m_LastUpdateBy.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public BaseExpressInc()
			{
				MarkNew();
			}						
			
			public BaseExpressInc GetOldValue()
			{
				return OldValue as BaseExpressInc;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：Seqno[]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CompanyName属性
			private string m_CompanyName = String.Empty;
			/// <summary>
			/// 属性名称： CompanyName
			/// 内容摘要： DB列名：Company_Name[]
			///            DB类型：string
			/// </summary>
			public string CompanyName
			{
				get
					{
						return m_CompanyName;
					}
				set
					{
						if (m_CompanyName as object == null || !m_CompanyName.Equals(value))
						{
							m_CompanyName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region QueryUrl属性
			private string m_QueryUrl = String.Empty;
			/// <summary>
			/// 属性名称： QueryUrl
			/// 内容摘要： DB列名：Query_URL[]
			///            DB类型：string
			/// </summary>
			public string QueryUrl
			{
				get
					{
						return m_QueryUrl;
					}
				set
					{
						if (m_QueryUrl as object == null || !m_QueryUrl.Equals(value))
						{
							m_QueryUrl = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Desc属性
			private string m_Desc = String.Empty;
			/// <summary>
			/// 属性名称： Desc
			/// 内容摘要： DB列名：Desc[]
			///            DB类型：string
			/// </summary>
			public string Desc
			{
				get
					{
						return m_Desc;
					}
				set
					{
						if (m_Desc as object == null || !m_Desc.Equals(value))
						{
							m_Desc = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateDate属性
			private DateTime m_CreateDate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： CreateDate
			/// 内容摘要： DB列名：Create_Date[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime CreateDate
			{
				get
					{
						return DateTime.Parse(m_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_CreateDate as object == null || !m_CreateDate.Equals(value))
						{
							m_CreateDate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateBy属性
			private string m_CreateBy = String.Empty;
			/// <summary>
			/// 属性名称： CreateBy
			/// 内容摘要： DB列名：Create_By[]
			///            DB类型：string
			/// </summary>
			public string CreateBy
			{
				get
					{
						return m_CreateBy;
					}
				set
					{
						if (m_CreateBy as object == null || !m_CreateBy.Equals(value))
						{
							m_CreateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LastUpdateDate属性
			private DateTime m_LastUpdateDate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： LastUpdateDate
			/// 内容摘要： DB列名：Last_update_Date[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime LastUpdateDate
			{
				get
					{
						return DateTime.Parse(m_LastUpdateDate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_LastUpdateDate as object == null || !m_LastUpdateDate.Equals(value))
						{
							m_LastUpdateDate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LastUpdateBy属性
			private string m_LastUpdateBy = String.Empty;
			/// <summary>
			/// 属性名称： LastUpdateBy
			/// 内容摘要： DB列名：Last_update_By[]
			///            DB类型：string
			/// </summary>
			public string LastUpdateBy
			{
				get
					{
						return m_LastUpdateBy;
					}
				set
					{
						if (m_LastUpdateBy as object == null || !m_LastUpdateBy.Equals(value))
						{
							m_LastUpdateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Company_Name",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Query_URL",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Create_Date",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Create_By",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Last_update_Date",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Last_update_By",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("CompanyName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("QueryUrl",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("LastUpdateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("LastUpdateBy",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["Company_Name"] = this.CompanyName;
					dr["Query_URL"] = this.QueryUrl;
					dr["Desc"] = this.Desc;
					dr["Create_Date"] = this.CreateDate;
					dr["Create_By"] = this.CreateBy;
					dr["Last_update_Date"] = this.LastUpdateDate;
					dr["Last_update_By"] = this.LastUpdateBy;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["CompanyName"] = this.CompanyName;
					dr["QueryUrl"] = this.QueryUrl;
					dr["Desc"] = this.Desc;
					dr["CreateDate"] = this.CreateDate;
					dr["CreateBy"] = this.CreateBy;
					dr["LastUpdateDate"] = this.LastUpdateDate;
					dr["LastUpdateBy"] = this.LastUpdateBy;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成BaseExpressInc对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseExpressInc对象</returns>
			public static BaseExpressInc Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				BaseExpressInc obj = new BaseExpressInc();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.CompanyName = (dr["Company_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Company_Name"],typeof(string));
					obj.QueryUrl = (dr["Query_URL"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Query_URL"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.CreateDate = (dr["Create_Date"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Create_Date"],typeof(DateTime));
					obj.CreateBy = (dr["Create_By"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Create_By"],typeof(string));
					obj.LastUpdateDate = (dr["Last_update_Date"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Last_update_Date"],typeof(DateTime));
					obj.LastUpdateBy = (dr["Last_update_By"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Last_update_By"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.CompanyName = (dr["CompanyName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CompanyName"],typeof(string));
					obj.QueryUrl = (dr["QueryUrl"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["QueryUrl"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.CreateDate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.CreateBy = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
					obj.LastUpdateDate = (dr["LastUpdateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["LastUpdateDate"],typeof(DateTime));
					obj.LastUpdateBy = (dr["LastUpdateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["LastUpdateBy"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成BaseExpressInc对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>BaseExpressInc对象</returns>
			public static BaseExpressInc Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的BaseExpressInc对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseExpressInc对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的BaseExpressInc对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>BaseExpressInc对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的BaseExpressInc对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseExpressInc对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(BaseExpressInc obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的BaseExpressInc对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseExpressInc对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			BaseExpressInc old = this.OldValue as BaseExpressInc;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.CompanyName = old.CompanyName;
					this.QueryUrl = old.QueryUrl;
					this.Desc = old.Desc;
					this.CreateDate = old.CreateDate;
					this.CreateBy = old.CreateBy;
					this.LastUpdateDate = old.LastUpdateDate;
					this.LastUpdateBy = old.LastUpdateBy;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region BaseExpressInc实体的内部Key类
			/// <summary>
			/// BaseExpressInc实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体BaseExpressInc的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
